package com.maxatime.web.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.maxatime.common.constant.BusinessContents;
import com.maxatime.pojo.entity.ExamStudentLianxi1;
import com.maxatime.service.ExamStudentLianxi1SER;

//4月份练习
@Controller
@RequestMapping("/ExamStudentLianxi1CON")
public class ExamStudentLianxi1CON {
	
	@Autowired
	ExamStudentLianxi1SER examStudentLianxi1SER;
	
	//查询
	@RequestMapping("/quest")
	@ResponseBody
	public Map<String, Object> quest(@RequestBody ExamStudentLianxi1 examStudentLianxi1){
		Map<String, Object> m = new HashMap<>();
		Map<String, Object> map = examStudentLianxi1SER.map(examStudentLianxi1);
		m.put(BusinessContents.CODE, "0000");
		m.put(BusinessContents.MSG, "交易成功");
		m.put(BusinessContents.DATA, map.get("list"));
		m.put("pageInfo", map.get("pageInfo"));
		return m;
	}
	//新增
	@RequestMapping("/save")
	@ResponseBody
	public Map<String, Object> save(@RequestBody ExamStudentLianxi1 examStudentLianxi1){
		Map<String, Object> m = new HashMap<>();
		examStudentLianxi1SER.insertSelective(examStudentLianxi1);
		m.put(BusinessContents.CODE, "1111");
		m.put(BusinessContents.MSG, "新增成功");
		return m;
	}
	//删除
	@RequestMapping("/del")
	@ResponseBody
	public Map<String, Object> del(@RequestBody String jsonStr){
		JSONObject jsonObj = JSONObject.parseObject(jsonStr);
		int pkId = jsonObj.getInteger("pkId");
		Map<String, Object> m = new HashMap<>();
		examStudentLianxi1SER.deleteByPrimaryKey(pkId);
		m.put(BusinessContents.CODE, "2222");
		m.put(BusinessContents.MSG, "删除成功");
		return m;
	}
	//反显
	@RequestMapping("/find")
	@ResponseBody
	public Map<String, Object> find(@RequestBody String jsonStr){
		JSONObject jsonObj = JSONObject.parseObject(jsonStr);
		int pkId = jsonObj.getInteger("pkId");
		Map<String, Object> m = new HashMap<>();
		ExamStudentLianxi1 find = examStudentLianxi1SER.find(pkId);
		m.put(BusinessContents.CODE, "3333");
		m.put(BusinessContents.MSG, "find成功");
		m.put(BusinessContents.DATA, find);
		return m;
	}
	//修改
	@RequestMapping("/update")
	@ResponseBody
	public Map<String, Object> update(@RequestBody ExamStudentLianxi1 examStudentLianxi1){
		Map<String, Object> m = new HashMap<>();
		examStudentLianxi1SER.updateByPrimaryKeySelective(examStudentLianxi1);
		m.put(BusinessContents.CODE, "4444");
		m.put(BusinessContents.MSG, "up成功");
		return m;
	}
		
	
}
